package edu.yzu.testspringboot002.config.interceptor;



import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

import java.util.Map;

public class GroupChatInterceptor implements HandshakeInterceptor {

//    @Override
//    public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
//        // 这里可以进行一些逻辑判断，比如从请求中获取用户信息、群组信息等进行权限验证等
//        // 如果验证通过返回true，否则返回false阻止连接建立
//        return true;
//    }


    @Override
    public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
        // 从请求参数中获取userId

        return true;  // 继续握手过程
    }


    @Override
    public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
        // 握手成功后的处理逻辑，可以为空
    }



}